' A QB64 program by b+ (a prolific programmer)
' Ported to BASIC Anywhere Machine by Charlie Veniot
' This program exported from BASIC Anywhere Machine (Version [5.2.3].[2023.08.08.01.01]) on 2023.08.14 at 16:58 (Coordinated Universal Time)

_Title "Particle Fountain" 'b+ 2020-08-27
Const nP = 50000
Type particle
    x As Single
    y As Single
    dx As Single
    dy As Single
    r As Single
    c As Long
End Type
Dim Shared p(1 To nP) As particle
DECLARE Sub new (i)
Screen _NewImage(1200, 600, 32)
_Delay .25
' _ScreenMove _Middle
For i = 1 To nP
    new (i)
Next
Color , &H002200

Do
    Cls
    If lp < nP Then lp = lp + 100
    For i = 1 To lp step 30
        p(i).dy = p(i).dy + .1
        p(i).x = p(i).x + p(i).dx
        p(i).y = p(i).y + p(i).dy
        If p(i).x < 0 Or p(i).x > _Width Then new(i)
        If p(i).y > _Height And p(i).dy > 0 Then
            p(i).dy = -.75 * p(i).dy: p(i).y = _Height - 5
        End If
        Circle (p(i).x, p(i).y), p(i).r, p(i).c
    Next
'    _Display
    _delay 0.001
    
Loop ' Until _KeyDown(27)
end

Sub new (i)
    p(i).x = _Width / 2 + Rnd * 20 - 10
    p(i).y = _Height + Rnd * 5
    p(i).dx = Rnd * 1 - .5
    p(i).dy = -10
    p(i).r = Rnd * 3
    p(i).c = _RGB32(50 * Rnd + 165, 50 * Rnd + 165, 255)
End Sub